#include<bits/stdc++.h>
using namespace std;
inline int read()
{
    int f=1,k=0;char c=getchar();
    while(c<'0'||c>'9')
    {
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9')
    {
        k=(k<<3)+(k<<1)+(c^48);
        c=getchar();
    }
    return f*k;
}
const int M=2e5+5;
int t,ans,n,a[M],p[M];
void dfs(int now)
{
    if(now>n)
    {
        int redlast=0,bluelast=0,res=0;
        for(int i=1;i<=n;i++)
        {
            if(p[i]==1)
            {
                if(redlast==a[i])res+=a[i];
                redlast=a[i];
            }
            else{
                if(bluelast==a[i])res+=a[i];
                bluelast=a[i];
            }
        }
        ans=max(ans,res);return ;
    }
    for(int i=0;i<=1;i++)
    {
        p[now]=i;dfs(now+1);
    }
    return ;
}
int main()
{
    freopen("color.in","r",stdin);
    freopen("color.out","w",stdout);
    t=read();
    while(t--)
    {
        n=read();ans=0;
        memset(a,0,sizeof(a));
        for(int i=1;i<=n;i++)a[i]=read();
        dfs(1);
        cout<<ans<<endl;
    }
    return 0;
}
